package com.fwtai.api;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * 购物车
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023-09-25 14:51:30
 * @QQ号码 444141300
 * @Email service@fwtai.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class ApiCartsDao{

  private final DaoHandle dao;

  public ApiCartsDao(final DaoHandle dao){
    this.dao = dao;
  }

  public BigDecimal queryGoodsPrice(final long kid){
    return dao.queryForBigDecimal("api_carts.queryGoodsPrice",kid);
  }

  public Long queryGoodsExist(final HashMap<String,Long> params){
    return dao.queryForLong("api_carts.queryGoodsExist",params);
  }

  public int updateCartsPlus(final HashMap<String,Object> params){
    return dao.execute("api_carts.updateCartsPlus",params);
  }

  public int editCarts(final HashMap<String,Object> params){
    return dao.execute("api_carts.editCarts",params);
  }

  public int addCarts(final HashMap<String,Object> params){
    return dao.execute("api_carts.addCarts",params);
  }

  public List<HashMap<String,Object>> listCarts(final PageFormData formData){
    return dao.queryForListHashMap("api_carts.listCarts",formData);
  }

  public List<HashMap<String,Object>> listAllCarts(final HashMap<String,Long> params){
    return dao.queryForListHashMap("api_carts.listAllCarts",params);
  }

  public int delAllCarts(final HashMap<String,Long> delParams){
    return dao.execute("api_carts.delAllCarts",delParams);
  }

  public int delByKeys(final HashMap<String,Object> params){
    return dao.execute("api_carts.delByKeys",params);
  }

  public Integer getCartsTotal(final Long loginId){
    return dao.queryForInteger("api_carts.getCartsTotal",loginId);
  }

  public HashMap<String,Object> getStoreId(final long loginId){
    return dao.queryForHashMap("api_carts.getStoreId",loginId);
  }

  public List<HashMap<String,Object>> queryStoreGoods(final HashMap<String,Object> params){
    return dao.queryForListHashMap("api_carts.queryStoreGoods",params);
  }
}